<template>
	<view class="myselfContainer">
		<view class="navBarContainer">
			<view class="navBar">
				<view class="back" @click="goBack">
					<view class="iconContainer">
						<u-icon name="arrow-left" size="20"></u-icon>
					</view>
				</view>
				<text class="title">我的</text>
				<view class="other">
					
				</view>
			</view>
		</view>
		<u-toast ref="uToast"></u-toast>
		<view class="myselfContent">
			<view class="headImg" :style="[{backgroundImage:'url('+allInfo.avatar+')'}]">
				
			</view>
			<view class="myselfInfo">
				<view class="name">
					{{allInfo.name}}
				</view>
				<view class="phoneNumber">
					{{beforePhone}}******{{afterPhone}}
				</view>
			</view>
		</view>
		<view class="operate">
			<view class="content" @click="gotoMyOrder">
				<view class="info">
					<view class="icon">
						
					</view>
					<view class="title">
						我的订单
					</view>
				</view>
				<view class="goto">
					<u-icon name="arrow-right" color="rgb(216,216,216)" size="20"></u-icon>
				</view>
			</view>
		</view>
		<view class="exit" @click="exit">
			退出登录
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				allInfo:{},
				beforePhone:'',
				afterPhone:''
			}
		},
		methods: {
			goBack(){
				uni.navigateBack()
			},
			gotoMyOrder(){
				uni.navigateTo({
					url:'./myOrder'
				})
			},
			async exit(){
				await uni.removeStorage({
					key:'STATE_KEY',
					success:(res)=>{
						this.$refs.uToast.show({
							type: 'success',
							title: '退登成功',
							message: "退登成功",
							iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png',
							complete(){
								uni.navigateTo({
									url:'./homePage'
								})
							}
						})
					}
				})
			}
		},
		mounted(){
			this.allInfo=uni.getStorageSync('STATE_KEY')
			this.beforePhone=this.allInfo.phone.slice(0,3)
			this.afterPhone=this.allInfo.phone.slice(9)
		}
	}
</script>

<style>
	page{
		background-color: rgb(250,250,250);
	}
</style>

<style lang="scss" scoped>
	.myselfContainer{
		.navBarContainer{
			width: 100vw;
			height: 200rpx;
			position: fixed;
			z-index: 99;
			top:0rpx;
			left: 0;
			background-color: #FFF;
			display: flex;
			align-items: center;
			justify-content: center;
			// margin-top: 30rpx;
			.navBar{
				width: 90%;
				margin: 0 auto;
				margin-top: 100rpx;
				background-color: #FFF;
				display: flex;
				align-items: center;
				justify-content: space-between;
				.back,.other{
					width: 70rpx;
				}
				.title{
					font-size: 30rpx;
				}
			}
		}
		.myselfContent{
			margin-top: 200rpx;
			display: flex;
			align-items: center;
			background-color: #FFF;
			width: 100vw;
			.headImg{
				margin-left: 20rpx;
				width: 120rpx;
				height: 120rpx;
				background-position: center;
				background-size: contain;
				border-radius: 50%;
				margin-bottom: 50rpx;
			}
			.myselfInfo{
				margin-left: 15rpx;
				display: flex;
				flex-direction: column;
				margin-bottom: 50rpx;
				.name{
					font-size: 38rpx;
				}
				.phoneNumber{
					margin-top: 5rpx;
					font-size: 24rpx;
				}
			}
		}
		.operate{
			width: 710rpx;
			background-color: #FFF;
			margin: 0 auto;
			margin-top: 20rpx;
			box-shadow: 0px 0px 10px rgb(219, 219, 219);
			border-radius: 20rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			.content{
				width: 92%;
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 15rpx;
				margin-bottom: 15rpx;
				.info{
					display: flex;
					align-items: center;
					.icon{
						width: 40rpx;
						height: 40rpx;
						background-color: aliceblue;
					}
					.title{
						margin-left: 15rpx;
						font-size: 26rpx;
					}
				}
			}
		}
		.exit{
			width: 710rpx;
			position: fixed;
			height: 90rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 28rpx;
			color: #FFF;
			background-color: rgb(228,0,48);
			border-radius: 15rpx;
			left: 20rpx;
			bottom: 50rpx;
		}
	}
</style>
